package gold.contest;

import gold.utils.InputUtil;

import java.util.Arrays;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC6064 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public int maxConsecutive(int bottom, int top, int[] special) {
            Arrays.sort(special);
            int maxInterval = 0;
            for (int i : special) {
                maxInterval = Math.max(maxInterval, i - bottom);
                bottom = i + 1;
            }

            maxInterval = Math.max(maxInterval, top - bottom + 1);
            return maxInterval;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(solution.maxConsecutive(2, 9, InputUtil.toIntegerArray("[4,6]")));
        System.out.println(solution.maxConsecutive(6, 8, InputUtil.toIntegerArray("[7,6,8]")));
    }

    public static void main(String[] args) throws Exception {
        LC6064 an = new LC6064();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
